home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Best of MacTutor - S…e Code for Volumes 1 to 5
/
The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin
/
Source Code
/
#50 (Nov 89)
/
Alternate Appl
/
Alternate.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-08-20
|
3KB
|
91 lines
/************************************************************************/
/* */
/* Source - Alternate.c */
/* Author - Alexander S. Colwell, Copyright (C) 1989 */
/* */
/* Purpose - This application will demostrate the AlternateCDEF */
/* scroll bar using THINK C's object stuff. */
/* */
/************************************************************************/
#include <Global.h> /* Global variable defs */
#include <CApplication.h> /* Application object defs */
#include <Commands.h> /* Command object defs */
#include <CBartender.h> /* Menu object defs */
#include <CDecorator.h> /* Window display object defs */
#include <CDesktop.h> /* Desktop layer object defs */
#include <CDocument.h> /* Document object defs */
#include <CEditText.h> /* Text edit object defs */
#include <CScrollPane.h> /* Scrolling pane object defs */
struct CAltDemoApp : CApplication { /* Application object */
void CreateDocument(void); /* Create text edit window method */
};
struct CAltDemoDoc : CDocument { /* Document object */
void NewFile(void); /* Make new (bogus) file method */
};
struct CAltDemoPane : CEditText { /* Text edit pane object */
void IEditPane(CView *anEnclosure, CBureaucrat *aSupervisor);
};
#define altWIND 500 /* "Alternate Demo" WIND template */
/* Define external references */
extern CApplication *gApplication;/* Application object */
extern CDecorator *gDecorator;/* Window display object */
extern CDesktop *gDesktop; /* Desktop view layer object */
extern CBartender *gBartender;/* Menu handler object */
void main()
{
gApplication = new(CAltDemoApp);/* Create new application object*/
gApplication->IApplication(4,4096L,2048L);/* Init application */
gApplication->Run(); /* Startup application execution */
gApplication->Exit(); /* Return to da "Finder" */
}
void CAltDemoApp::CreateDocument()
{
CAltDemoDoc *theDocument; /* Working new document object */
theDocument = new(CAltDemoDoc);/* Create new document object */
theDocument->IDocument(this,FALSE);/* Initialize document object*/
theDocument->NewFile(); /* Create new (bogus) document file */
}
void CAltDemoDoc::NewFile(void)
{
CScrollPane *theScrollPane; /* Working scroll pane object */
CAltDemoPane *theMainPane;/* Working main pane object */
itsWindow = new(CWindow); /* Create new window object */
itsWindow->IWindow(altWIND,FALSE,gDesktop,this);
theScrollPane = new(CScrollPane);/* Create window's scrolling obj*/
theScrollPane->IScrollPane(itsWindow,this,10,10,0,0,sizELASTIC,sizELASTIC,
TRUE,TRUE,TRUE);
theScrollPane->FitToEnclFrame(TRUE, TRUE);
theMainPane = new(CAltDemoPane);
itsMainPane = theMainPane;
itsGopher = theMainPane;
theMainPane->IEditPane(theScrollPane,this);
theScrollPane->InstallPanorama(theMainPane);
itsWindow->Select(); /* Select our window now!! */
}
void CAltDemoPane::IEditPane(CView *anEnclosure, CBureaucrat *aSupervisor)
{
Rect margin; /* Working margin rect area */
/* Setup text edit stuff */
CEditText::IEditText(anEnclosure,aSupervisor,1,1,0,0,sizELASTIC,sizELASTIC,432);
FitToEnclosure(TRUE,TRUE);
SetRect(&margin,2,2,-2,-2);
ChangeSize(&margin,FALSE);
}